package top.techqi.usbd.desc

import top.techqi.core.util.FmtUtil

class ZerothDesc(
    bLength: Byte,
    bDescriptorType: Byte,
    vararg val bytes: Byte
) : AbstractDesc(bLength, bDescriptorType) {
    constructor(bytes: ByteArray) : this(
        bytes[0],
        bytes[1],
        *bytes.sliceArray(2..<bytes.size)
    )

    override fun toString(): String {
        return """
        ZerothDesc(
            bLength          = %1${'$'}s,
            bDescriptorType  = %2${'$'}s,
            bytes            = %3${'$'}s
        )
        """.trimIndent().format(
            bLength,
            bDescriptorType,
            bytes.joinToString(",") { FmtUtil.toHexString(it, "") }
        )
    }
}
